package com.example.its2021606134chh.LifeIndexModule;

import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.viewpager.widget.PagerAdapter;

import java.util.List;

/**
 * @ClassName: IndexViewPagerAdapter$
 * @Description: 作用
 * @Author: letquit
 * @CreateDate: 2021/6/21$
 * @Version: 1.0
 */
public class IndexViewPagerAdapter extends PagerAdapter {
    private List<View> list;

    public IndexViewPagerAdapter(List<View> list) {
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup viewGroup,int position) {
        viewGroup.addView(list.get(position));
        return list.get(position);
    }

    @Override
    public void destroyItem(ViewGroup viewGroup, int position, Object object) {
        viewGroup.removeView(list.get(position));
    }
}

